<?php

namespace App\Models;

use App\Models\base\WarehouseModel;
use App\Models\dispatch\CarModel;
use App\Models\dispatch\DriverModel;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Model as BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;


class PreTakeModel extends BaseModel
{
    protected $table = 't_customer_pre_take';

    protected $primaryKey = 'id';

    public $timestamps = true;

    const CREATED_AT = 'created_at';
    
    const UPDATED_AT = null;

    const STATUS_CUS = [1 => '未安排司机', 2 => '已安排司机', 3 => '取件中', 4 => '已取件', 5 => '取件失败', 6 => '送回仓库'];

    const STATUS = [1 => '未安排司机', 2 => '已安排司机', 3 => '取件中', 4 => '运回中', 5 => '取件失败', 6 => '送回仓库'];

    protected $guarded = [];

    protected $hidden = [
        'deleted_at',
    ];


    //货物信息
    public function goods(): HasMany {
        return $this->HasMany(PreGoodsModel::class, 'pre_id');
    }

    //省
    public function province(): BelongsTo {
        return $this->belongsTo(AddressModel::class, 'province_id');
    }

    //市
    public function city(): BelongsTo {
        return $this->belongsTo(AddressModel::class, 'city_id');
    }

    //区
    public function district(): BelongsTo {
        return $this->belongsTo(AddressModel::class, 'district_id');
    }

    //车辆
    public function car(): BelongsTo {
        return $this->belongsTo(CarModel::class, 'car_id');
    }

    //司机
    public function driver(): BelongsTo {
        return $this->belongsTo(DriverModel::class, 'driver_id');
    }

    //仓库
    public function warehouse(): BelongsTo {
        return $this->belongsTo(WarehouseModel::class, 'warehouse_id');
    }

}
